//@file:JvmName("Utils") 更改编译成java的类名
package com.example.mykotlinapp.util

import java.lang.StringBuilder

/**
 *
 * 工具函数类
 *
 * @author zhudeshuai
 * @since 2019/6/27
 */

fun <T> joinToString(
    collection: Collection<T>,
    separator: String = ",",
    prefix: String = "",
    postfix: String = ""
): String {
    val result = StringBuilder(prefix)
    for ((index, element) in collection.withIndex()) {
        if (index > 0) result.append(separator)
        result.append(element)
    }
    result.append(postfix)
    return result.toString()
}